﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using DotnetSpider.DataFlow.Parser;
using DotnetSpider.DataFlow.Parser.Formatters;
using DotnetSpider.DataFlow.Storage;
using DotnetSpider.HBase;
using DotnetSpider.Http;
using DotnetSpider.RabbitMQ;
using DotnetSpider.Sample.samples;
using DotnetSpider.Scheduler.Component;
using DotnetSpider.Selector;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Serilog;
using Serilog.Events;

namespace DotnetSpider.Lawyee
{
    class Program
    {
		static async Task Main(string[] args)
		{

			ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

			System.Net.ServicePointManager.MaxServicePoints = 0;

			System.Net.ServicePointManager.MaxServicePointIdleTime = 1;


			Log.Logger = new LoggerConfiguration()
				.MinimumLevel.Information()
				.MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Warning)
				.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
				.MinimumLevel.Override("System", LogEventLevel.Warning)
				.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Warning)
				.Enrich.FromLogContext()
				.WriteTo.Console().WriteTo.RollingFile("logs/spider.txt")
				.CreateLogger();
			   
			try
			{ 
				await Lawyee.Src.LawSpider.RunAsync(); 
			}
			catch (Exception ex)
			{
				Log.Logger.Error(ex.ToString());
			}

			Console.WriteLine("Bye!");
			Environment.Exit(0);
		}
	}
}
